<template>
  <div class="submit-record" v-loading="records.loading">
    <el-table
      :data="records.rows"
      style="width: 100%">
      <el-table-column
        prop="index"
        label="序号"
        align="center"
        type="index"
        width="60">
      </el-table-column>

      <el-table-column
        prop="positionName"
        label="职位名称">
      </el-table-column>

      <el-table-column
        prop="companyName"
        label="招聘公司">
      </el-table-column>
      <el-table-column
        label="查阅状态"
        width="120">
        <template slot-scope="scope">
          {{scope.row.applyStatus === 'NO' ? '待查看' : '已查看'}}
        </template>
      </el-table-column>

      <el-table-column
        label="投递日期"
        width="120">
        <template slot-scope="scope">
          {{$formatYMD(scope.row.ctime)}}
        </template>
      </el-table-column>
      
      <el-table-column
        label="操作"
        width="120">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="seePosition(scope.row)">岗位详情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="list-page">
      <el-pagination
        :current-page="records.pageIndex"
        :page-sizes="[10, 20, 30, 50]"
        :page-size="records.pageSize"
        class="fr"
        layout="sizes, prev, pager, next"
        :total="records.count">
      </el-pagination>
    </div>
  </div>
</template>
<script>
import PagedList from '../../libs/PagedList.js'

export default {
  name: 'submitrecord',
  title: '投递记录',
  data() {
    return {
      records: new PagedList('/mscs/resume/findResumesRecord', 20, {userId: this.$store.state.user.user.user.userId}),
      listtotal: 100
    }
  },
  mounted () {
    this.records.search()
  },
  methods: {
    seePosition (row) {
      let str = ''
      if (row.isDelete === 'YES') {
        str = '职位已经被删除，无法查看'
      } else if (row.positionStatus === 'INVALID') {
        str = '职位已经下线，无法查看'
      } else if (new Date().getTime() > row.validityPeriod) {
        str = '职位已过期，无法查看'
      }

      if (str.length > 0) {
        this.$alert(str, {
          confirmButtonText: '确定',
        })
        return 
      }
      const {href} = this.$router.resolve({
        name: 'recruitdetails',
        params: {id: this.$compileStr(row.positionId)}
      })
      window.open(href, '_blank')
    }
  }
}
</script>
<style lang='scss'>
  .submit-record {
    .el-table {
      border-top: 1px solid #94C05A;
      margin-top: 30px;
      th {
        background-color: #E4EED8;
        color: #666666;
      }
      td {
        background-color: #F3F9EB;
      }
    }
  }
</style>